<?php
	include("DBConn.php");
	$client = $_POST['client'];
?>
<html>
<body style="background-image:url(pedobear.bmp); background-repeat: no-repeat; background-size: 70%;">
<?php
	$link = connectToDB();
	$strquery = "select * from items_taken where TAKER='$client';";
	$result = mysql_query($strquery) or die(mysql_error());
	$num = mysql_num_rows($result);
	if($num!=0){
	echo "<br></br>";
	echo "<center><font size='7'><b>$client</b></font></center>";
	?>
		<center>
		<p/>
		<br></br>
		<br></br>
		<fieldset>
		<legend><b><font size="5">Detailed Client's Log</font></b></legend>
		<table border="1" cellspacing="0" width="80%">
			<tr>
			<?php
			
			while ($field=mysql_fetch_field($result)) {
			echo "<th>";
			echo "<center>$field->name</center>";
			echo "</th>";
			}
			echo "</tr>";

			while ($row = mysql_fetch_row($result)) {
			echo "<tr>";
			for ($i=0; $i<mysql_num_fields($result); $i++) {
			echo "<td>";
				echo "<center>$row[$i]</center>";
			echo "</td>";
			}
			echo "</tr>\n";
			}

		echo "</table></center></fieldset>";
		
	$strquery1 = "select ITEM_NAME, sum(QUANTITY) Total_Used from items_taken where TAKER='$client' group by ITEM_NAME;";
	$result1 = mysql_query($strquery1) or die(mysql_error());
	?>
		<center>
		<p/>
		<fieldset>
		<legend>Tallied Client's Log</legend>
		<table border="1" cellspacing="0" width="60%">
			<tr>
			<?php
			
			while ($field=mysql_fetch_field($result1)) {
			echo "<th>";
			echo "<center>$field->name</center>";
			echo "</th>";
			}
			echo "</tr>";

			while ($row = mysql_fetch_row($result1)) {
			echo "<tr>";
			for ($i=0; $i<mysql_num_fields($result1); $i++) {
			echo "<td>";
				echo "<center>$row[$i]</center>";
			echo "</td>";
			}
			echo "</tr>\n";
			}

		echo "</table></center></fieldset>";
		}
		else echo "<center><h1>$client did not take anything yet pouz. :)</h1></center>";
			mysql_close($link);

		?>
</body>
</html>